package tgc.edu.xzy.controller;

import java.util.HashMap;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HomeController {
	//请求映射,当接收到名字为home，则访问view文件夹中home.jsp文件
	//与spring-mvc.xml文件下配置文件相结合
	//@RequestMapping指定请求地址
	@RequestMapping(value="/home",method = RequestMethod.GET)
	//ModelMap用来像页面传递值
	public String home(ModelMap map) {
		map.put("user", "张三");
		//返回名字为home.jsp的文件名
		return "home";
	}
	
	@RequestMapping(value= {"/index", "/"})
	public String index() {
		return "index";
	}
	
	@RequestMapping(value="/abc")
	@ResponseBody
	public Object abc(String name){
		HashMap<String, Object> result = new HashMap<>();
		result.put("value", name+"你好");
		return name;
	}
}
